package com.example.springaopdemo.controller;

import com.example.springaopdemo.model.ClassRoom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/room")
public class ClassRoomController {
    @Autowired
    private ApplicationContext context;

    @Autowired
    private ClassRoom single;
    @Autowired
    private ClassRoom prototype;
    @Autowired
    private ClassRoom request;
    @Autowired
    private ClassRoom session;
    @Autowired
    private ClassRoom application;

    @RequestMapping("/single")
    public String single(){
        ClassRoom single1 = context.getBean("single", ClassRoom.class);
        return "context: "+single1 +" 属性注入: "+single;

    }

    @RequestMapping("/prototype")
    public String prototype(){
        ClassRoom single1 = context.getBean("prototype", ClassRoom.class);
        return "context: "+single1 +" 属性注入: "+prototype;

    }

    @RequestMapping("/request")
    public String request(){
        ClassRoom single1 = context.getBean("request", ClassRoom.class);
        return "context: "+single1 +" 属性注入: "+request;

    }

    @RequestMapping("/session")
    public String session(){
        ClassRoom single1 = context.getBean("session", ClassRoom.class);
        return "context: "+single1 +" 属性注入: "+session;

    }

    @RequestMapping("/application")
    public String application(){
        ClassRoom single1 = context.getBean("application", ClassRoom.class);
        return "context: "+single1 +" 属性注入: "+application;

    }


}
